# Entity class
# An Entity is basically any in-game
# object which can be as abstract as
# the inventory of an Actor.

from crl_mapmngr import MapMngr

class EntityDescriptor:
  __slots__ = [
    "name", "desc"]
  
  def __init__(self, name, desc):
    self.name = name
    self.desc = desc
  
  def getName(self):
    return self.name
  
  def getDescription(self):
    return self.desc

class Entity:
  __slots__ = [
    "locx", "locy", "desc"]
  
  def __init__(self):
    self.locx = 0
    self.locy = 0
    self.desc = None
  
  def setDescriptor(self, desc):
    self.desc = desc
  
  def getDescriptor(self):
    return self.desc
  
  def getName(self):
    return self.desc.getName()
  
  def getDescription(self):
    return self.desc.getDescription()

  def setLocation(self, x, y):
    self.locx = x
    self.locy = y
  
  def getLocationX(self):
    return self.locx
  
  def getLoactionY(self):
    return self.locy
  
  def moveTo(self, nx, ny):
    if MapMngr.get().canMoveTo(self, nx, ny):
      self.setLocation(nx, ny)
